package org.framegen.solon;

import lombok.extern.slf4j.Slf4j;

import org.framegen.config.AppFrameworkEnum;
import org.framegen.core.AbstractEntry;
import org.framegen.core.FrameGenExecutor;
import org.framegen.solon.service.SolonDataSourceFactory;
import org.framegen.solon.util.SolonContextHolder;
import org.noear.solon.core.AppContext;

@Slf4j
public class FrameGenSolonEntry extends AbstractEntry<FrameGenSolonEntry> {

    public FrameGenSolonEntry(AppContext context) {
        this(context, null);
    }

    public FrameGenSolonEntry(AppContext context, String dataSourceName) {
        super(new SolonDataSourceFactory(context).getDataSource(), dataSourceName, AppFrameworkEnum.SOLON);
    }

    public FrameGenSolonEntry create(AppContext context) {
        return new FrameGenSolonEntry(context);
    }

    public FrameGenSolonEntry create(AppContext context, String dataSourceName) {
        return new FrameGenSolonEntry(context, dataSourceName);
    }

    @Override
    public FrameGenSolonEntry self() {
        return this;
    }

    @Override
    protected Class<? extends FrameGenExecutor> getExecutorClass() {
        return FrameGenSolonExecutor.class;
    }

    public void start() {
        run();
    }
}
